<template>
  <el-row :gutter="10">
    <el-col :xs="24" :sm="24" :lg="4"  style="height: 226px;">
      <el-row :gutter="10" class="panel-group" style="height: 226px;">
        <el-col :xs="24" :sm="24" :lg="24" class="card-panel-col" style="height: 226px;">
          <div class="card-panel" style="height: 226px;" @click="toRouterPath('/wms/wmsdatas')">
            <el-result subTitle="累计接收" :title="''+allRecives+''">
              <template slot="subTitle">
                  <div class="total-text">
                    累计接收
                  </div>
                </template>
                <template slot="title">
                    <div class="total-value">
                      {{allRecives}}
                    </div>
                  </template>
              <template slot="icon">
                  <div class="card-panel-icon-wrapper icon-example" style="margin: 0;">
                    <svg-icon icon-class="checkbox" class-name="card-panel-icon" />
                  </div>
                </template>
            </el-result>
          </div>
        </el-col>
      </el-row>
    </el-col>
    <el-col :xs="20" :sm="20" :lg="16" >
      <el-row :gutter="10" class="panel-group">
        <el-col :xs="24" :sm="24" :lg="8" class="card-panel-col">
          <div class="card-panel" @click="toRouterPath('/wms/wmsdatas')">
            <div class="card-panel-icon-wrapper icon-message">
              <svg-icon icon-class="log" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                已接收物品
              </div>
              <count-to :start-val="0" :end-val="properties.receives+(properties.receivesOrder?properties.receivesOrder:0)" style="margin-left: 10px;" :duration="3000" class="card-panel-num" />
            </div>
          </div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="card-panel-col">
          <div class="card-panel" @click="toRouterPath('/wms/putTask')">
            <div class="card-panel-icon-wrapper icon-example">
              <svg-icon icon-class="job" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                待上架物品
              </div>
              <count-to :start-val="0" :end-val="properties.unputs" style="margin-left: 20px;" :duration="3600" class="card-panel-num" />
            </div>
          </div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="card-panel-col">
          <div class="card-panel" @click="toRouterPath('/wms/wmsdatas')">
            <div class="card-panel-icon-wrapper icon-tree">
              <svg-icon icon-class="redis" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                库存物品
              </div>
              <count-to :start-val="0" :end-val="properties.nums" style="margin-left: 20px;" :duration="3200" class="card-panel-num" />
            </div>
          </div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="card-panel-col">
          <div class="card-panel" @click="toRouterPath('/wms/wmsdatas')">
            <div class="card-panel-icon-wrapper icon-form">
              <svg-icon icon-class="skill" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                已接收车辆
              </div>
              <count-to :start-val="0" :end-val="bus.receives+(bus.receivesOrder?bus.receivesOrder:0)" style="margin-left: 20px;" :duration="3600" class="card-panel-num" />
            </div>
          </div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="card-panel-col">
          <div class="card-panel" @click="toRouterPath('/wms/putTask')">
            <div class="card-panel-icon-wrapper icon-job">
              <svg-icon icon-class="time-range" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                待入库车辆
              </div>
              <count-to :start-val="0" :end-val="bus.unputs" style="margin-left: 20px;" :duration="3600" class="card-panel-num" />
            </div>
          </div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="card-panel-col" @click="toRouterPath('/wms/putTask')">
          <div class="card-panel" @click="toRouterPath('/wms/wmsdatas')">
            <div class="card-panel-icon-wrapper icon-people">
              <svg-icon icon-class="tree-table" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                库存车辆
              </div>
              <count-to :start-val="0" :end-val="bus.nums" style="margin-left: 20px;" :duration="2600" class="card-panel-num" />
            </div>
          </div>
        </el-col>

      </el-row>
    </el-col>
    <el-col :xs="24" :sm="24" :lg="4"  style="height: 226px;">
      <el-row :gutter="10" class="panel-group" style="height: 226px;">
        <el-col :xs="24" :sm="24" :lg="24" class="card-panel-col" style="height: 226px;">
          <div class="card-panel" style="height: 226px;" @click="toRouterPath('/wms/wmsdatas')">
            <el-result icon="success" subTitle="累计库存" :title="''+allTotals+''">
              <template slot="subTitle">
                  <div class="total-text">
                    累计库存
                  </div>
                </template>
                <template slot="title">
                    <div class="total-value">
                      {{allTotals}}
                    </div>
                  </template>
              <template slot="icon">
                  <div class="card-panel-icon-wrapper icon-message" style="margin: 0;">
                    <svg-icon icon-class="monitor" class-name="card-panel-icon" />
                  </div>
                </template>
            </el-result>
          </div>
        </el-col>
      </el-row>
    </el-col>
  </el-row>

</template>

<script>
import CountTo from 'vue-count-to'
import {indexCount,indexCountV2} from "@/api/statistics/index";

export default {
  components: {
    CountTo
  },
  data() {
    return {
      properties:{
        receives:0,
        unputs:0,
        nums:0
      },
      bus:{
        receives:0,
        unputs:0,
        nums:0
      },
      allTotals:0,
      allRecives:0,
      currentDay:undefined
    }
  },
  created() {
    this.currentDay = this.parseTime(new Date(),'{y}-{m}-{d} {h}:{m}');
    this.initData()
  },
  methods: {
    initData(){
      indexCountV2().then(response=>{
        if(response.data && response.data.properties){
          this.properties = response.data.properties;
          this.allTotals = this.allTotals + response.data.properties.nums;
          this.allRecives = this.allRecives + (response.data.properties.receives + response.data.properties.receivesOrder);
        }
        if(response.data && response.data.bus){
          this.bus = response.data.bus;
          this.allTotals = this.allTotals + response.data.bus.nums;
          this.allRecives = this.allRecives + (response.data.bus.receives + response.data.bus.receivesOrder);
        }
      })
    },
    toRouterPath(path){
      this.$router.push({
        path: path,
        query: {
          pageNum: 1
        }
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 5px;

  .card-panel-col {
    margin-bottom: 10px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
      .icon-tree {
        background: #73c0de
      }
      .icon-example {
        background: #91cc75;
      }
      .icon-form {
        background: #fecc66
      }
      .icon-job {
        background: #fd8008
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }
   .icon-tree {
      color: #73c0de
    }

    .icon-example {
      color: #91cc75;
    }

    .icon-form {
      color: #fecc66
    }

    .icon-job {
      color: #fd8008
    }
    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
    .total-text{
      color: rgba(0, 0, 0, 0.45);
      font-size: 16px;
      font-weight: bold;
    }
    .total-value{
      font-size: 22px;
      font-weight: bold;
      color: #666;
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
